package com.ant.backstage.utils.validation.impl;

import com.ant.backstage.utils.validation.CustomerValidationUtils;
import com.ant.backstage.utils.validation.inter.CheckPwd;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

@Component
public class CheckPwdValidation implements ConstraintValidator<CheckPwd, String> {

    @Override
    public void initialize(CheckPwd constraintAnnotation) {
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        if (StringUtils.isEmpty(value)) {
            return false;
        } else {
            return CustomerValidationUtils.checkPwd(value);
        }
    }
}
